﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Collections.Generic;

public partial class DayToDayManagement_ProductCommentDetail : System.Web.UI.Page
{
    protected void Page_PreInit(object sender, EventArgs e)
    {
        Page.Theme = BLL.Common.GetWSMThemes();
    }
    private string ProductID
    {
        get
        {
            return Request.QueryString["productId"] != null ? Request.QueryString["productId"].ToString() : "";        
        }
    }

    private string Level
    {
        get
        {
            return Request.QueryString["level"] != null ? Request.QueryString["level"].ToString() : "";
        }
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (this.ProductID != null && this.Level != "")
            {
                AspNetPager1.PageSize = Convert.ToInt32(ConfigurationManager.AppSettings["RowCountPerPage"].ToString());
                BindRepeater();
            }
        }
    }

    private void BindRepeater()
    {
        int rowCount;
        Repeater1.DataSource = new BLL.COMMODITY_EVAL().GetCommentStatisticsByProductIdAndCommentLevel(GetStartIndex(AspNetPager1.CurrentPageIndex, AspNetPager1.PageSize), AspNetPager1.PageSize, this.ProductID, this.Level, out rowCount);
        Repeater1.DataBind();
        AspNetPager1.RecordCount = rowCount;
    }

    protected void AspNetPager1_PageChanged(object sender, EventArgs e)
    {
        BindRepeater();
    }

    private int GetStartIndex(int pageIndex, int pageSize)
    {
        return 1 + (pageIndex - 1) * pageSize;
    }
}
